using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;

namespace BlackBlade.ListActions.ClearList
{
    public class ClearListAction
    {
        public static void ClearList(SPList ListToClear)
        {
            ClearList(ListToClear, ListToClear.Items.Count);
        }

        public static int ClearList(SPList ListToClear, int BatchSize)
        {
            int intDeletedItemCount = 0;
            while (ListToClear.Items.Count > 0 && intDeletedItemCount < BatchSize)
            {
                ListToClear.Items[0].Delete();
                intDeletedItemCount++;
            }

            return ListToClear.ItemCount;
        }
    }
}
